#ifndef _GlsxSound_H_
#define _GlsxSound_H_

	
#ifdef GlsxSound_EXPORTS
	#define GlsxSound_API __declspec (dllexport)
#else
	#define GlsxSound_API __declspec (dllimport)
#endif


namespace GlsxSound {


	enum TStreamFormat
	{
		sfUnknown = 0,
		sfMp3 = 1,
		sfOgg = 2,
		sfWav = 3,
		sfPCM = 4,
		sfFLAC = 5,
		sfFLACOgg = 6,
		sfAC3 = 7,
		sfAacADTS = 8,
		sfWaveIn = 9,
		sfAutodetect = 1000
	};


#define WaveOutWaveMapper 0xFFFFFFFF
#define WaveInWaveMapper 0xFFFFFFFF

	enum TFFTGraphSize
	{
		FFTGraphMinWidth = 100,
		FFTGraphMinHeight = 60
	};


	enum TBMPDetectionMethod
	{
		dmPeaks = 0,
		dmAutoCorrelation = 1
	};


	enum TFFTGraphHorizontalScale
	{
		gsLogarithmic = 0,
		gsLinear = 1
	};


	enum TSeekMethod
	{
		smFromBeginning = 1,
		smFromEnd = 2,
		smFromCurrentForward = 4,
		smFromCurrentBackward = 8
	};



	enum TTimeFormat
	{
		tfMillisecond = 1,
		tfSecond = 2,
		tfHMS = 4,
		tfSamples = 8
	};

	typedef struct {
		unsigned int hour;
		unsigned int minute;
		unsigned int second;
		unsigned int millisecond;
	} TStreamHMSTime;


	typedef struct {
		unsigned int sec;
		unsigned int ms;
		unsigned int samples;
		TStreamHMSTime hms;
	} TStreamTime;


	typedef struct {
		int nLeftDelay;	
		int nLeftSrcVolume;	
		int nLeftEchoVolume;
		int nRightDelay;
		int nRightSrcVolume;
		int nRightEchoVolume;
	} TEchoEffect;


	enum TWaveOutFormat
	{
		format_invalid = 0,
		format_11khz_8bit_mono = 1,
		format_11khz_8bit_stereo = 2,
		format_11khz_16bit_mono = 4,
		format_11khz_16bit_stereo = 8,
		format_22khz_8bit_mono = 16,
		format_22khz_8bit_stereo = 32,
		format_22khz_16bit_mono = 64,
		format_22khz_16bit_stereo = 128,
		format_44khz_8bit_mono = 256,
		format_44khz_8bit_stereo = 512,
		format_44khz_16bit_mono = 1024,
		format_44khz_16bit_stereo = 2048
	};


	enum TWaveOutFunctionality
	{
		supportPitchControl = 1,
		supportPlaybackRateControl = 2,
		supportVolumeControl = 4,
		supportSeparateLeftRightVolume = 8,
		supportSync = 16,
		supportSampleAccuratePosition = 32,
		supportDirectSound = 6
	}; 


	typedef struct {
		unsigned int ManufacturerID;
		unsigned int ProductID;
		unsigned int DriverVersion;
		unsigned int Formats;
		unsigned int Channels;
		unsigned int Support;
		char *ProductName;
	} TWaveOutInfo;


	typedef struct {
		unsigned int ManufacturerID;
		unsigned int ProductID;
		unsigned int DriverVersion;
		unsigned int Formats;
		unsigned int Channels;
		unsigned int Support;
		wchar_t *ProductName;
	} TWaveOutInfoW;



	typedef struct {
		unsigned int ManufacturerID;
		unsigned int ProductID;
		unsigned int DriverVersion;
		unsigned int Formats;
		unsigned int Channels;
		char *ProductName;
	} TWaveInInfo;


	typedef struct {
		unsigned int ManufacturerID;
		unsigned int ProductID;
		unsigned int DriverVersion;
		unsigned int Formats;
		unsigned int Channels;
		wchar_t *ProductName;
	} TWaveInInfoW;



	typedef struct {
		int fPlay;
		int fPause;
		int fEcho;
		int fEqualizer;	
		int fVocalCut;
		int fSideCut;
		int fChannelMix;
		int fSlideVolume;
		int nLoop;
		int fReverse;
		int nSongIndex;
		int nSongsInQueue;
	} TStreamStatus;

	enum TID3Version
	{
		id3Version1 = 1,
		id3Version2 = 2
	};

	typedef struct {
		char *Title;
		char *Artist;
		char *Album;
		char *Year;
		char *Comment;
		char *TrackNum; 
		char *Genre;
	} TID3Info;


	typedef struct {
		unsigned int PicturePresent;
		unsigned int CanDrawPicture;
		char *MIMEType;
		int PictureType;
		char *Description;
		void *PictureData;
		unsigned int PictureDataSize;
		void *hBitmap;
		unsigned int Width;
		unsigned int Height;
		char reserved[128];
	} TID3Picture;

	typedef struct {
		unsigned int PicturePresent;
		unsigned int CanDrawPicture;
		wchar_t *MIMEType;
		int PictureType;
		wchar_t *Description;
		void *PictureData;
		unsigned int PictureDataSize;
		void *hBitmap;
		unsigned int Width;
		unsigned int Height;
		char reserved[128];
	} TID3PictureW;

	typedef struct {
		char *Title;
		char *Artist;
		char *Album;
		char *Year;
		char *Comment;
		char *TrackNum; 
		char *Genre;
		char *AlbumArtist;
		char *Composer;
		char *OriginalArtist;
		char *Copyright;
		char *URL;
		char *Encoder;
		char *Publisher;
		unsigned int BPM;
		TID3Picture Picture;
		char reserved[128];
	} TID3InfoEx;

	typedef struct {
		wchar_t *Title;
		wchar_t *Artist;
		wchar_t *Album;
		wchar_t *Year;
		wchar_t *Comment;
		wchar_t *TrackNum; 
		wchar_t *Genre;
		wchar_t *AlbumArtist;
		wchar_t *Composer;
		wchar_t *OriginalArtist;
		wchar_t *Copyright;
		wchar_t *URL;
		wchar_t *Encoder;
		wchar_t *Publisher;
		unsigned int BPM;
		TID3PictureW Picture;
		char reserved[128];
	} TID3InfoExW;


	typedef struct {
		wchar_t *Title;
		wchar_t *Artist;
		wchar_t *Album;
		wchar_t *Year;
		wchar_t *Comment;
		wchar_t *TrackNum; 
		wchar_t *Genre;
	} TID3InfoW;



	typedef struct {
		int SamplingRate;
		int ChannelNumber;
		int VBR;
		int Bitrate;
		TStreamTime Length;
		char *Description;
	} TStreamInfo;


	typedef struct {
		int SamplingRate;
		int ChannelNumber;
		int VBR;
		int Bitrate;
		TStreamTime Length;
		wchar_t *Description;
	} TStreamInfoW;


	typedef struct {
		unsigned int NumberOfBuffers;
		unsigned int NumberOfBytes;
	} TStreamLoadInfo;


	enum TFFTGraphType
	{
		gtLinesLeftOnTop = 0,
		gtLinesRightOnTop,
		gtAreaLeftOnTop,
		gtAreaRightOnTop,
		gtBarsLeftOnTop,
		gtBarsRightOnTop,
		gtSpectrum
	};


	enum TFFTWindow
	{
		fwRectangular = 1,
		fwHamming,
		fwHann,
		fwCosine,
		fwLanczos,
		fwBartlett,
		fwTriangular,
		fwGauss,
		fwBartlettHann,
		fwBlackman,
		fwNuttall,
		fwBlackmanHarris,
		fwBlackmanNuttall,
		fwFlatTop
	};



	enum TFFTGraphParamID
	{
		gpFFTPoints = 1,
		gpGraphType,
		gpWindow,
		gpHorizontalScale,
		gpSubgrid,
		gpTransparency,
		gpFrequencyScaleVisible,
		gpDecibelScaleVisible,
		gpFrequencyGridVisible,
		gpDecibelGridVisible,
		gpBgBitmapVisible,
		gpBgBitmapHandle,
		gpColor1,
		gpColor2,
		gpColor3,
		gpColor4,
		gpColor5,
		gpColor6,
		gpColor7,
		gpColor8,
		gpColor9,
		gpColor10,
		gpColor11,
		gpColor12,
		gpColor13,
		gpColor14,
		gpColor15,
		gpColor16

	};

	enum  TCallbackMessage
	{

		MsgStopAsync = 1,
		MsgPlayAsync = 2,
		MsgEnterLoopAsync = 4,
		MsgExitLoopAsync = 8,
		MsgEnterVolumeSlideAsync = 16,
		MsgExitVolumeSlideAsync = 32,
		MsgStreamBufferDoneAsync = 64,
		MsgStreamNeedMoreDataAsync = 128,
		MsgNextSongAsync = 256,
		MsgStop = 65536,
		MsgPlay = 131072,
		MsgEnterLoop = 262144,
		MsgExitLoop = 524288,
		MsgEnterVolumeSlide = 1048576,
		MsgExitVolumeSlide = 2097152,
		MsgStreamBufferDone = 4194304,
		MsgStreamNeedMoreData = 8388608,
		MsgNextSong = 16777216,
		MsgWaveBuffer = 33554432
	};


	typedef int  (__stdcall * TCallbackFunc)(void* instance, void *user_data, TCallbackMessage message, unsigned int param1, unsigned int param2);


	enum TSettingID {
		sidWaveBufferSize = 1,
		sidAccurateLength = 2,
		sidAccurateSeek = 3,
		sidSamplerate = 4,
		sidChannelNumber = 5,
		sidBitPerSample = 6,
		sidBigEndian = 7,
		sidWaveInBufferSize = 8
	};

	class ZPlay
	{
	public:

		virtual int __stdcall SetSettings(TSettingID nSettingID, int nValue) = 0;
		virtual int __stdcall GetSettings(TSettingID nSettingID) = 0;
		virtual int __stdcall GetVersion() = 0;
		virtual char * __stdcall GetError() = 0;	
		virtual wchar_t * __stdcall GetErrorW() = 0;
		virtual TStreamFormat __stdcall GetFileFormat(const char *pchFileName) = 0;	
		virtual TStreamFormat __stdcall GetFileFormatW(const wchar_t *pchFileName) = 0;
		virtual int __stdcall EnumerateWaveOut() = 0;
		virtual int __stdcall GetWaveOutInfo(unsigned int nIndex, TWaveOutInfo *pWaveOutInfo) = 0;
		virtual int __stdcall GetWaveOutInfoW(unsigned int nIndex, TWaveOutInfoW *pWaveOutInfo) = 0;
		virtual int __stdcall SetWaveOutDevice(unsigned int nIndex) = 0;
		virtual int __stdcall OpenFile(const char *sFileName, TStreamFormat nFormat)= 0;	
		virtual int __stdcall OpenFileW(const wchar_t *sFileName, TStreamFormat nFormat)= 0;		
		virtual int __stdcall AddFile(const char *sFileName, TStreamFormat nFormat)= 0;
		virtual int __stdcall AddFileW(const wchar_t *sFileName, TStreamFormat nFormat)= 0;
		virtual int __stdcall OpenStream(int fBuffered, int fDynamic, const void *sMemStream, unsigned int nStreamSize, TStreamFormat nFormat) = 0;
		virtual int __stdcall PushDataToStream(const void *sMemNewData, unsigned int nNewDataize) = 0;
		virtual int __stdcall IsStreamDataFree(const void *sMemNewData) = 0;
		virtual void __stdcall GetDynamicStreamLoad(TStreamLoadInfo *pStreamLoadInfo) = 0;
		virtual void __stdcall GetStreamInfo(TStreamInfo *pInfo) = 0;
		virtual void __stdcall GetStreamInfoW(TStreamInfoW *pInfo) = 0;
		virtual int __stdcall Close() = 0;
		virtual int __stdcall Play() = 0;
		virtual int __stdcall PlayLoop(TTimeFormat fFormatStartTime, TStreamTime *pStartTime, TTimeFormat fFormatEndTime, TStreamTime *pEndTime, unsigned int nNumOfCycles, unsigned int fContinuePlaying) = 0;
		virtual int __stdcall Seek(TTimeFormat fFormat, TStreamTime *pTime, TSeekMethod nMoveMethod) = 0;
		virtual int __stdcall ReverseMode(int fEnable) = 0;
		virtual int __stdcall Stop() = 0;
		virtual int __stdcall Pause() = 0;
		virtual int __stdcall Resume() = 0;
		virtual void __stdcall GetPosition(TStreamTime *pTime) = 0;
		virtual int __stdcall SetMasterVolume(unsigned int nLeftVolume, unsigned int nRightVolume) = 0;
		virtual int __stdcall SetPlayerVolume(unsigned int nLeftVolume, unsigned int nRightVolume) = 0;
		virtual void __stdcall GetMasterVolume(unsigned int *pnLeftVolume, unsigned int *pnRightVolume) = 0;
		virtual void __stdcall GetPlayerVolume(unsigned int *pnLeftVolume,unsigned int *pnRightVolume) = 0;
		virtual int __stdcall GetBitrate(int fAverage) = 0;
		virtual void __stdcall GetStatus(TStreamStatus *pStatus) = 0;
		virtual int __stdcall MixChannels(int fEnable, unsigned int nLeftPercent, unsigned int nRightPercent) = 0;
		virtual void __stdcall GetVUData(unsigned int *pnLeftChannel, unsigned int *pnRightChannel) = 0;
		virtual int __stdcall SlideVolume(int fFormatStart, TStreamTime *pTimeStart, unsigned int nStartVolumeLeft, unsigned int nStartVolumeRight, int fFormatEnd, TStreamTime *pTimeEnd, unsigned int nEndVolumeLeft,unsigned int nEndVolumeRight) = 0;
		//virtual int __stdcall EnableEqualizer(int fEnable) = 0;
		//virtual int __stdcall SetEqualizerPoints(int *pnFreqPoint, int nNumOfPoints) = 0;
		//virtual int __stdcall GetEqualizerPoints(int *pnFreqPoint, int nFreqPointNumber) = 0;
		//virtual int __stdcall SetEqualizerParam(int nPreAmpGain, int *pnBandGain, int nNumberOfBands) = 0;
		//virtual int __stdcall GetEqualizerParam(int *pnPreAmpGain, int *pnBandGain,	int nNumberOfBands) = 0;
		//virtual int __stdcall SetEqualizerPreampGain(int nGain) = 0;
		//virtual int __stdcall GetEqualizerPreampGain() = 0; 
		//virtual int __stdcall SetEqualizerBandGain(int nBandIndex, int nGain) = 0;
		//virtual int __stdcall GetEqualizerBandGain(int nBandIndex) = 0;
		virtual int __stdcall LoadID3(TID3Version nId3Version, TID3Info *pId3Info) = 0;
		virtual int __stdcall LoadID3W(TID3Version nId3Version,	TID3InfoW *pId3Info) = 0;
		virtual int __stdcall LoadFileID3(const char *pchFileName, TStreamFormat nFormat, TID3Version nId3Version, TID3Info *pId3Info) = 0;
		virtual int __stdcall LoadFileID3W(const wchar_t *pchFileName, TStreamFormat nFormat, TID3Version nId3Version, TID3InfoW *pId3Info) = 0;
		//virtual int __stdcall EnableEcho(int fEnable) = 0;
		//virtual int __stdcall SetEchoParam(TEchoEffect *pEchoEffect, int nNumberOfEffects) = 0;
		//virtual int __stdcall GetEchoParam(TEchoEffect *pEchoEffect, int nNumberOfEffects) = 0;
		virtual int __stdcall SetCallbackFunc(TCallbackFunc pCallbackFunc,TCallbackMessage nMessages, void *user_data) = 0;
		//virtual int __stdcall SetRate(unsigned int nRate)= 0;
		//virtual unsigned int __stdcall GetRate()= 0;
		//virtual int __stdcall SetPitch(unsigned int nPitch)= 0;
		//virtual unsigned int __stdcall GetPitch()= 0;
		//virtual int __stdcall SetTempo(unsigned int nTempo)= 0;
		//virtual unsigned int __stdcall GetTempo()= 0;
		//virtual int __stdcall StereoCut(int fEnable, int fOutputCenter, int fBassToSides)= 0;
		virtual void __stdcall Release() = 0;
		//virtual int __stdcall DetectBPM(TBMPDetectionMethod nMethod) = 0;
		//virtual int __stdcall DetectFileBPM(const char *pchFileName, TStreamFormat nFormat, TBMPDetectionMethod nMethod)= 0;
		//virtual int __stdcall DetectFileBPMW(const wchar_t *pchFileName, TStreamFormat nFormat, TBMPDetectionMethod nMethod)= 0;
		//virtual int __stdcall GetFFTData(int nFFTPoints, TFFTWindow nFFTWindow, int *pnHarmonicNumber,int *pnHarmonicFreq,int *pnLeftAmplitude,int *pnRightAmplitude,int *pnLeftPhase,int *pnRightPhase) = 0;
		//virtual int __stdcall DrawFFTGraphOnHDC(void* hdc, int nX, int nY, int nWidth, int nHeight) = 0;
		//virtual int __stdcall DrawFFTGraphOnHWND(void* hwnd, int nX, int nY, int nWidth, int nHeight) = 0;
		//virtual int __stdcall SetFFTGraphParam(TFFTGraphParamID nParamID, int nValue) = 0;
		//virtual int __stdcall GetFFTGraphParam(TFFTGraphParamID nParamID) = 0;

		// new inferface in ver. 2.0  - 23.04.2010.
		virtual int __stdcall LoadID3Ex(TID3InfoEx *pId3Info, unsigned int fDecodeEmbededPicture) = 0;
		virtual int __stdcall LoadID3ExW(TID3InfoExW *pId3Info, unsigned int fDecodeEmbededPicture) = 0;
		virtual int __stdcall LoadFileID3Ex(const char *pchFileName, TStreamFormat nFormat, TID3InfoEx *pId3Info, unsigned int fDecodeEmbededPicture) = 0;
		virtual int __stdcall LoadFileID3ExW(const wchar_t *pchFileName, TStreamFormat nFormat, TID3InfoExW *pId3Info, unsigned int fDecodeEmbededPicture) = 0;
		//virtual int __stdcall DrawBitmapToHDC(void *hdc, int X, int Y, int Width, int Height, void *hBitmap) = 0;
		//virtual int __stdcall DrawBitmapToHWND(void *hwnd, int X, int Y, int Width, int Height, void *hBitmap) = 0;
		virtual int __stdcall EnumerateWaveIn() = 0;
		virtual int __stdcall GetWaveInInfo(unsigned int nIndex, TWaveInInfo *pWaveInInfo) = 0;
		virtual int __stdcall GetWaveInInfoW(unsigned int nIndex, TWaveInInfoW *pWaveInInfo) = 0;
		virtual int __stdcall SetWaveInDevice(unsigned int nIndex) = 0;

		virtual int __stdcall SetWaveOutFile(const char *sFileName, TStreamFormat nFormat, unsigned int fOutputToSoundcard)= 0;
		virtual int __stdcall SetWaveOutFileW(const wchar_t *sFileName, TStreamFormat nFormat, unsigned int fOutputToSoundcard)= 0;

	};

#ifdef __cplusplus
extern "C" {
#endif

GlsxSound_API  ZPlay *  __stdcall CreateSound(); 

#ifdef __cplusplus
}
#endif

}

#endif


